package com.shuizhu.template.demo1;

import com.alibaba.excel.EasyExcel;
import com.alibaba.excel.write.builder.ExcelWriterBuilder;
import com.alibaba.excel.write.builder.ExcelWriterSheetBuilder;
import com.shuizhu.template.StudentByFill;

import java.util.Date;


public class OneLineFill {
  
  public static void main(String[] args) {
    //要填充的Excel模板的路径
    String templatePath = "C:\\Users\\tianyunjie\\Desktop\\temp\\fill2.xlsx";
    
    //获取工作簿对象（整个Excel文件）
    ExcelWriterBuilder workBook = EasyExcel
        .write("C:\\Users\\tianyunjie\\Desktop\\temp\\fill-demo.xlsx", StudentByFill.class)
        //与模板进行关联
        .withTemplate(templatePath);
    
    //获取Sheet对象
    ExcelWriterSheetBuilder sheet = workBook.sheet();
    
    //创建需要被填充的数据
    StudentByFill fillData = new StudentByFill("20222410666", "张三", new Date(978567730000L), "男", 21035.00, "信息工程学院");
    
    //执行数据填充
    sheet.doFill(fillData);//do开头的方法会自在操作结束后，自动关闭流
  }
  
}

